using SqlQueryBuilder.Queries;
using SqlQueryBuilder.Util;

namespace SqlQueryBuilder.Clauses
{
    /// <summary>
    /// Class to construct Where clauses
    /// </summary>
    public static class Condition
    {
        /// <summary>
        /// Ins the specified field.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="field">The field.</param>
        /// <param name="valueList">The value list.</param>
        /// <returns></returns>
        public static IConditionalClause In<T>(string field, params T[] valueList)
        {
            return new In<T>(field, valueList);
        }

        /// <summary>
        /// Ands the specified conditional clauses.
        /// </summary>
        /// <param name="conditionalClauses">The conditional clauses.</param>
        /// <returns></returns>
        public static IConditionalClause And(params IConditionalClause[] conditionalClauses)
        {
            return new And(conditionalClauses);
        }

        /// <summary>
        /// Ors the specified conditional clauses.
        /// </summary>
        /// <param name="conditionalClauses">The conditional clauses.</param>
        /// <returns></returns>
        public static IConditionalClause Or(params IConditionalClause[] conditionalClauses)
        {
            return new Or(conditionalClauses);
        }

        /// <summary>
        /// Betweens the specified field.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="field">The field.</param>
        /// <param name="minValue">The min value.</param>
        /// <param name="maxValue">The max value.</param>
        /// <returns></returns>
        public static IConditionalClause Between<T>(string field, T minValue, T maxValue)
        {
            return new Between<T>(field,minValue,maxValue);
        }

        /// <summary>
        /// Likes the specified field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="value">The value.</param>
        /// <param name="likeType">Type of the like.</param>
        /// <returns></returns>
        public static IConditionalClause Like(string field, string value, LikeType likeType)
        {
            return new Like(field, value, likeType);
        }

        /// <summary>
        /// Determines whether the specified field is null.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <returns></returns>
        public static IConditionalClause IsNull(string field)
        {
            return new IsNull(field);
        }

        /// <summary>
        /// Nots the specified clause.
        /// </summary>
        /// <param name="clause">The clause.</param>
        /// <returns></returns>
        public static IConditionalClause Not(IConditionalClause clause)
        {
            return new Not(clause);
        }

        /// <summary>
        /// Ins the specified field.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <param name="selectQuery">The select query.</param>
        /// <returns></returns>
        public static IConditionalClause InQuery(string field, IInterrogationQuery selectQuery)
        {
            return new In<object>(field, selectQuery);
        }
    }
}